package com.leyou.gateway.config;

import com.leyou.common.auth.utils.RsaUtils;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.security.PublicKey;

@Data
@ConfigurationProperties(prefix = "ly.jwt")
public class JwtProperties implements InitializingBean {

    private String pubKeyPath;

    private PublicKey publicKey;

    private UserTokenProperties user=new UserTokenProperties();
    private AppTokenProperties app=new AppTokenProperties();


    @Override
    public void afterPropertiesSet() throws Exception {
        this.publicKey= RsaUtils.getPublicKey(pubKeyPath);

    }

    @Data
    public class UserTokenProperties{

        private String cookieName;
    }

    @Data
    public class AppTokenProperties{
        private Long id;
        private String secret;
        private String headerName;

    }

}
